package com.netrust.cmsx.entity.module.site;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
* @title  用戶角色中间表
* @description
* @author   ZYC
* @version  v_1.0.0
* @date   2017年6月14日 下午4:51:11
*/
@Entity
@Table(name = "t_site_user_role")
public class SiteUserRole implements Serializable{

	private static final long serialVersionUID = -3189487731688084040L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "u_r_id", unique = true, nullable = false)
	private Integer id;//主鍵
	
	@Column(name = "t_su_id",nullable = false)
	private Integer userId;//用戶id
	
	@Column(name = "t_r_id",nullable = false)
	private Integer roleId;//角色id

	public SiteUserRole() {
		super();
	}

	public SiteUserRole(Integer id, Integer userId, Integer roleId) {
		super();
		this.id = id;
		this.userId = userId;
		this.roleId = roleId;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public Integer getRoleId() {
		return roleId;
	}

	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((roleId == null) ? 0 : roleId.hashCode());
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SiteUserRole other = (SiteUserRole) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (roleId == null) {
			if (other.roleId != null)
				return false;
		} else if (!roleId.equals(other.roleId))
			return false;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "SiteUserRole [id=" + id + ", userId=" + userId + ", roleId=" + roleId + "]";
	}
	

}
